import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import Backend from 'i18next-xhr-backend';
import { initReactI18next } from 'react-i18next';
import translationEN from '@app-cad/assets/locales/en/translation.json';
import translationCN from '@app-cad/assets/locales/zh-CN/translation.json';

const resources = {
  en: { translation: translationEN },
  zh_CN: { translation: translationCN },
};

i18n
  .use(Backend)
  .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    resources,
    lng: 'zh_CN',
    fallbackLng: 'en',
    interpolation: {
      escapeValue: false,
    },
    debug: false,
  });

export default i18n;
